package com.myproject;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

/**
 * Created by zhaobo on 2016/12/21.
 */

public class FirstActivity extends Activity implements View.OnClickListener {
    private Button btn_run1;
    private Button btn_run2;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.first);
        init();
        btn_run1.setOnClickListener(this);
        btn_run2.setOnClickListener(this);
    }

    private void init() {
        btn_run1 = (Button) findViewById(R.id.btn_run1);
        btn_run2 = (Button) findViewById(R.id.btn_run2);
    }

    private void toActivity(Class<? extends Activity> clazz) {
        Intent intent = new Intent(this, clazz);
        startActivity(intent);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.btn_run1:
                toActivity(TestActivity1.class);
                break;
            case R.id.btn_run2:
                toActivity(TestActivity2.class);
                break;
        }
    }
}
